DeleteKey

The DeleteKey method deletes a key and all its subkeys and named values from the registry.

Caution You should be particularly careful when deleting keys from the registry. Deleting critical registry keys and named values can render your machine unusable.

Syntax

DeleteKey FullKeyname [,Flush]

Parameters

FullKeyname
A string that specifies full name of the registry key.

This can be a key on either a local or a remote machine. Keys on a remote machine are specified by prefixing the key name with the machine name. For example:

\\RemoteMachine\HKLM\Software\MyProg


Flush
This optional parameter is a BOOLEAN that specifies whether the registry changes that this method makes should be written to the disk immediately.

If Flush is set to TRUE, the method immediately writes the registry changes to the disk. Note that immediately flushing registry changes to the disk may reduce server performance.

If Flush is FALSE, the method does not immediately write the registry changes to the disk. They are instead written to the disk by the registry's lazy flusher or when the system shuts down.

The default is FALSE.

Example

The following example deletes from the registry both the key HKEY_CURRENT_USER\Software\MyCompany and all its subkeys and named values.
<% 
Set MyReg = Server.CreateObject("IISSample.Registry")
MyReg.DeleteKey "HKEY_CURRENT_USER\Software\MyCompany"
 %> 
 

Applies To

Registry Access Component

See Also

DeleteValue